package titt.io.util.wrap;

import titt.io.socket.out.TITTOutputStream;
import titt.util.io.pipe.PipeListener;

public class ByteWrapper implements Wrapper {

	@Override
	public boolean supports(Object o) {
		return o instanceof byte[];
	}

	@Override
	public void writeTo(PipeListener listener, TITTOutputStream out, Object o) throws Exception {
		byte[] b = (byte[])o;
		
		out.write(b);
	}

	@Override
	public String getMimeType(Object o) {
		return "application/octet-stream";
	}
	
	@Override
	public int getLength(Object o) {
		return ((byte[])o).length;
	}

}
